public class Commondivisor {
    public static void main(String[] args) {
        int a = 18;
        int b = 24;
        int c = a%b;
        while (c!=0){
            a = b;
            b = c;
            c = a %b;
        }
        System.out.println(b);
    }
}
